<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>23通信班</title>
    <style>
        body {
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            font-family: 'Microsoft YaHei', sans-serif;
        }

        .container {
            text-align: center;
            background: rgba(255, 255, 255, 0.95);
            padding: 3rem;
            border-radius: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
            width: 90%;
            max-width: 600px;
        }

        h1 {
            color: #2c3e50;
            margin-bottom: 2rem;
            font-size: 2.5rem;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
        }

        .name-display {
            font-size: 3.5rem;
            margin: 2.5rem 0;
            color: #34495e;
            min-height: 120px;
            display: flex;
            align-items: center;
            justify-content: center;
            background: #f8f9fa;
            border-radius: 15px;
            padding: 1.5rem;
            box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
            transition: all 0.3s;
        }

        .btn {
            padding: 1.2rem 2.5rem;
            font-size: 1.3rem;
            border: none;
            border-radius: 30px;
            cursor: pointer;
            background: #4CAF50;
            color: white;
            transition: all 0.3s;
            text-transform: uppercase;
            letter-spacing: 1px;
            margin: 0 0.5rem;
        }

        .btn:hover {
            transform: translateY(-2px);
            box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
        }

        .btn.stop {
            background: #ff4757;
        }

        .rolling {
            animation: shake 0.1s infinite;
            color: #e74c3c;
        }

        @keyframes shake {
            0% {
                transform: translateX(-2px);
            }

            50% {
                transform: translateX(2px);
            }

            100% {
                transform: translateX(-2px);
            }
        }

        @media (max-width: 480px) {
            .container {
                padding: 2rem;
            }

            h1 {
                font-size: 2rem;
            }

            .name-display {
                font-size: 2.5rem;
            }
        }
    </style>
</head>
<!-- 
    范宗凯  -2
-->

<body>
    <div class="container">
        <h1>🎉 随机点名系统</h1>
        <div id="display" class="name-display">准 备 就 绪</div>
        <button id="actionBtn" class="btn">开 始</button>
    </div>

    <script>
        const originalStudents = [
            '陈艳玲',
            '邓嘉诚',
            '杜奇',
            '范宗凯',
            '方伊萍',
            '何宝林',
            '何泽方',
            '洪梓云',
            '黄俊杰',
            '黄骑龙',
            '姜晓琴',
            '雷聪',
            '黎梓瑜',
            '李浩东',
            '李军',
            '梁光涛',
            '刘崇彬',
            '刘伟',
            '聂宇文',
            '谭华盛',
            '万星扬',
            '王楠',
            '王旭',
            '温巧玲',
            '温鑫',
            '吴敦国',
            '吴佳琦',
            '谢国宝',
            '谢伟达',
            '鄢智蔚',
            '杨婧',
            '易圣航',
            '易梓晨',
            '赵思逸',
            '赵毅豪',
            '钟纹萍',
            '周佳佳'
        ];
        let availableStudents = [...originalStudents];
        let isRunning = false;
        let intervalId = null;
        const display = document.getElementById('display');
        const actionBtn = document.getElementById('actionBtn');

        function getRandomStudent() {
            if (availableStudents.length === 0) {
                return '所有学生已点过名';
            }
            const randomIndex = Math.floor(Math.random() * availableStudents.length);
            return availableStudents[randomIndex];
        }

        actionBtn.addEventListener('click', function () {
            if (isRunning) {
                // 停止抽选 
                clearInterval(intervalId);
                isRunning = false;
                actionBtn.textContent = '开 始';
                actionBtn.classList.remove('stop');
                display.classList.remove('rolling');

                const selectedStudent = display.textContent;
                if (selectedStudent !== '所有学生已点过名') {
                    const index = availableStudents.indexOf(selectedStudent);
                    if (index !== -1) {
                        availableStudents.splice(index, 1);
                    }
                }
            } else {
                // 开始抽选 
                isRunning = true;
                actionBtn.textContent = '停 止';
                actionBtn.classList.add('stop');
                display.classList.add('rolling');

                intervalId = setInterval(() => {
                    display.textContent = getRandomStudent();
                }, 10);
            }
        }); 
    </script>
</body>

</html>